package initialize

import (
	"github.com/APP/internal/service/system_service"
	"time"

	"github.com/APP/global"
	"github.com/songzhibin97/gkit/cache/local_cache"
)

func OtherInit() {
	dr, err := ParseDuration(global.APP_CONFIG.JWT.ExpiresTime)
	if err != nil {
		panic(err)
	}
	_, err = ParseDuration(global.APP_CONFIG.JWT.BufferTime)
	if err != nil {
		panic(err)
	}

	global.BlackCache = local_cache.NewCache(
		local_cache.SetDefaultExpire(dr),
	)

	// 加载JWT黑名单
	if global.APP_DB != nil {
		jwtService := system_service.JwtService{}
		jwtService.LoadAll()
	}
}

func ParseDuration(d string) (time.Duration, error) {
	return time.ParseDuration(d)
}
